home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / clsboltnut.cls < prev    next >
Encoding:
Visual Basic class definition  |  2004-03-05  |  32.8 KB  |  1,065 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "Detail"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. Option Explicit
  15. '/******************************************************************/
  16. '/*                                                                */
  17. '/*                      TurboCAD for Windows                      */
  18. '/*                   Copyright (c) 1993 - 2001                    */
  19. '/*             International Microcomputer Software, Inc.         */
  20. '/*                            (IMSI)                              */
  21. '/*                      All rights reserved.                      */
  22. '/*                                                                */
  23. '/******************************************************************/
  24.  
  25. 'DBAPI constants
  26. Const gkGraphic = 11
  27. Const gkArc = 2
  28. Const gkText = 6
  29. Const gfCosmetic = 128&
  30.  
  31. 'Useful math constants
  32. Const Pi# = 3.14159265
  33.  
  34. 'Real variant types!
  35. Const typeEmpty = 0
  36. Const typeInteger = 2
  37. Const typeLong = 3
  38. Const typeSingle = 4
  39. Const typeDouble = 5
  40. Const typeCurrency = 6
  41. Const typeDate = 7
  42. Const typeString = 8
  43. Const typeObject = 9
  44. Const typeBoolean = 11
  45. Const typeVariant = 12
  46. Const typeIntegerEnum = typeInteger + 100
  47. Const typeLongEnum = typeLong + 100
  48. Const typeStringEnum = typeString + 100
  49.  
  50. 'Stock property pages
  51. Const ppStockPen = 1
  52. Const ppStockBrush = 2
  53. Const ppStockText = 4
  54. Const ppStockInsert = 8
  55. Const ppStockViewport = 16
  56. Const ppStockAuto = 32
  57.  
  58. 'Property Ids
  59. Const idBoltType = 1
  60. Const idNutType = 2
  61. Const idDiam = 3
  62.  
  63. 'Property enums
  64. Const NUM_TYPEBOLT = 2
  65. Const Bolt1 = 0
  66. Const Bolt2 = 1
  67. Const NUM_TYPENUT = 2
  68. Const Nut1 = 0
  69. Const Nut2 = 1
  70.  
  71.  
  72. 'Number of properties, pages, wizards
  73. Const NUM_PROPERTIES = 3
  74. Const NUM_PAGES = 1
  75. Const NUM_WIZARDS = 0
  76. Const formCaption = "Bolt-Nut"
  77.  
  78. Private Sub Class_Initialize()
  79.     'Initialize class variables
  80. End Sub
  81.  
  82. 'Returns the user-visible description of this RegenMethod
  83. Public Property Get Description() As String
  84.     Description = "BoltNut"
  85. End Property
  86.  
  87. 'Returns the persistent class id for this RegenMethod's property section
  88. Public Property Get ClassID() As String
  89.     ClassID = "{FDB6F1C1-9631-11d1-A40A-0000B465872B}"
  90. End Property
  91.  
  92. 'Retrieve types and names
  93. Public Function GetPropertyInfo(Names As Variant, Types As Variant, _
  94.     IDs As Variant, Defaults As Variant) As Long
  95.     ReDim Names(NUM_PROPERTIES), Types(NUM_PROPERTIES), _
  96.         IDs(NUM_PROPERTIES), Defaults(NUM_PROPERTIES)
  97.     Names(0) = "BoltType"
  98.     Types(0) = typeLong
  99.     IDs(0) = idBoltType
  100.     Defaults(0) = Bolt1
  101.     
  102.     Names(1) = "NutType"
  103.     Types(1) = typeLong
  104.     IDs(1) = idNutType
  105.     Defaults(1) = Nut1
  106.     
  107.     Names(2) = "Diameter"
  108.     Types(2) = typeDouble
  109.     IDs(2) = idDiam
  110.     Defaults(2) = 0.5
  111.     
  112.     GetPropertyInfo = NUM_PROPERTIES
  113. End Function
  114.  
  115. 'Get the number of property pages supporting this RegenMethod
  116. Public Function GetPageInfo(ByVal AGraphic As Object, StockPages As Long, _
  117.     Names As Variant) As Long
  118.     ReDim Names(NUM_PAGES)
  119.  
  120.     'Need the form
  121. '    Load frmBoltNut
  122. '    Names(0) = frmBoltNut.Caption
  123. '    Unload frmBoltNut
  124.     Names(0) = formCaption
  125.     StockPages = ppStockBrush + ppStockPen + ppStockAuto
  126.     GetPageInfo = NUM_PAGES
  127. End Function
  128.  
  129. Public Function GetWizardInfo(Names As Variant) As Long
  130.     ReDim Names(NUM_WIZARDS)
  131.     GetWizardInfo = NUM_WIZARDS
  132. End Function
  133.  
  134. 'Enumerate the names and values of a specified property
  135. Public Function GetEnumNames(ByVal PropID As Long, Names As Variant, Values As Variant) As Long
  136.  
  137.     If PropID = idBoltType Or PropID = idNutType Then
  138. ReDim Names(NUM_TYPEBOLT), Value(NUM_TYPEBOLT)
  139.         Names(0) = "Bolt1"
  140.         Values(0) = Bolt1
  141.     
  142.         Names(1) = "Bolt2"
  143.         Values(1) = Bolt2
  144.         GetEnumNames = NUM_TYPEBOLT
  145.         Exit Function
  146.     End If
  147.     If PropID = idNutType Then
  148. ReDim Names(NUM_TYPENUT), Value(NUM_TYPENUT)
  149.         Names(0) = "Nut1"
  150.         Values(0) = Nut1
  151.     
  152.         Names(1) = "Nut2"
  153.         Values(1) = Nut2
  154.         GetEnumNames = NUM_TYPENUT
  155.         Exit Function
  156.     End If
  157.         
  158.         GetEnumNames = 0
  159.     
  160. End Function
  161.  
  162. Public Function PageControls(ByVal ThisRegenMethod As Object, ByVal Graphic As Object, ByVal PageNumber As Long, ByVal SaveProperties As Boolean) As Boolean
  163.         'Set up error function
  164.         On Error GoTo Failed
  165. Dim i%, j%
  166. Dim Diameter#
  167. Dim iDiam%
  168.         If SaveProperties Then
  169.             'OK button on property page was clicked
  170.             'Form is still loaded
  171.             With frmBoltNut
  172.                 'Need On Error statement for the case where you have
  173.                 'RRect Turbo Shape and ahother "shape" selected
  174.                 On Error Resume Next
  175.                 For i = 0 To NUM_TYPEBOLT
  176.                     If .BoltType(i).Value Then
  177.                         Graphic.Properties("BoltType") = i
  178.                         Exit For
  179.                     End If
  180.                 Next i
  181.                 For j = 0 To NUM_TYPENUT
  182.                     If .NutType(j).Value Then
  183.                         Graphic.Properties("NutType") = j
  184.                         Exit For
  185.                     End If
  186.                 Next j
  187. '                iDiam = .ListDiam.ListIndex
  188. '                Graphic.Properties("Diameter") = iDiam
  189.                 Diameter = 0#
  190.                 On Error Resume Next
  191.                 Diameter = CDbl(.ListDiam.Text)
  192.                 If Diameter < 0.00001 Then Diameter = 0.5
  193.                                 
  194.                 Graphic.Properties("Diameter") = Diameter
  195.                 
  196.                 'When the property page is closed, transfer the numeric
  197.                 'Diameter value from the TextBox to the Graphic
  198.                 'Get the value as a double-precision number
  199.                 
  200.                 'Make sure it's between 0 and 100
  201.                 
  202.                 'Set the roundness property value in the Graphic
  203.             End With
  204.         Else
  205.             'Property page is about to be opened
  206.             'Make sure the form is loaded
  207.             Load frmBoltNut
  208.             With frmBoltNut
  209.             
  210. Dim BoltProp As Variant
  211.                 BoltProp = Graphic.Properties("BoltType")
  212.                 If VarType(BoltProp) <> vbEmpty Then
  213.                     i = CInt(BoltProp)
  214.                     .BoltType(i).Value = True
  215.                 End If
  216. Dim NutProp As Variant
  217.                 NutProp = Graphic.Properties("NutType")
  218.                 If VarType(NutProp) <> vbEmpty Then
  219.                     j = CInt(NutProp)
  220.                     .NutType(j).Value = True
  221.                 End If
  222. '                iDiam = Graphic.Properties("Diameter")
  223. '                .ListDiam.ListIndex = iDiam
  224.                 Diameter = Graphic.Properties("Diameter")
  225. Dim Diami#
  226.                 iDiam = -1
  227.                 For i = 0 To .ListDiam.ListCount - 1
  228.                     Diami = CDbl(.ListDiam.List(i))
  229.                     If Abs(Diameter - Diami) < 0.00001 Then
  230.                         iDiam = i
  231.                     End If
  232.                 Next i
  233.                 If iDiam = -1 Then iDiam = 4
  234.                 
  235.                 .ListDiam.ListIndex = iDiam
  236.                                 
  237.                 'If more than one RRect is selected and they do not
  238.                 'have the same properties, don't set up this field
  239.                 On Error GoTo NoRType
  240.  
  241.                 'When the property page is opening, transfer the numeric
  242.                 'roundness value from the Graphic to the TextBox
  243.                 'Get the roundness property value from the Graphic
  244.                 'Set the TextBox control's text
  245. NoRType:
  246.             End With
  247.         End If
  248.  
  249.         PageControls = True
  250.         Exit Function
  251.  
  252. Failed:
  253.         'For debugging purposes, report that an error occurred
  254.         If Err.Number <> 0 Then
  255.             MsgBox "Error in PageControls: " & Err.Description
  256.         End If
  257.  
  258.         'Return false if an error occurred
  259.         PageControls = False
  260. End Function
  261.  
  262. Public Function PageDone(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant)
  263.         'Done with form
  264.         Unload frmBoltNut
  265. End Function
  266.  
  267. Public Function PropertyPages(ByVal ThisRegenMethod As Object, Optional PageNumber As Variant) As Boolean
  268.     With frmBoltNut
  269.         .Show vbModal
  270.         PropertyPages = Not .DialogCanceled
  271.     End With
  272. End Function
  273.  
  274. Public Function Wizard(ByVal ThisRegenMethod As Object, Optional WizardNumber As Variant) As Boolean
  275.     Wizard = False
  276. End Function
  277.  
  278. 'Called when vertex has been moved, or other geometry change
  279. Public Function OnGeometryChanged(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant)
  280.     'Do nothing
  281. End Function
  282.  
  283. 'Called when vertex is moved, or other geometry change
  284. Public Function OnGeometryChanging(ByVal Graphic As Object, ByVal GeomID As Long, paramOld As Variant, paramNew As Variant) As Boolean
  285.     'OK to continue with change
  286.     OnGeometryChanging = True
  287. End Function
  288.  
  289. Public Function OnNewGraphic(ByVal grfThis As Object, ByVal boolCopy As Boolean) As Boolean
  290.     If boolCopy Then
  291.         'Vertices are already added for us...
  292.         OnNewGraphic = True
  293.         Exit Function
  294.     End If
  295.  
  296.     On Error GoTo Failed
  297.     'New Graphic being created
  298.     'X, Y, Z, PenDown, Selectable, Snappable, Editable, Linkable
  299.     'First Vertex is "first point of axis"
  300.     grfThis.Vertices.Add 0#, 0#, 0#, False, True, False, True, False
  301.     
  302.     'Second Vertex is "Second point of axis"
  303.     
  304.     grfThis.Vertices.Add 3#, 0#, 0#, False, True, False, True, False
  305.     
  306.     grfThis.Properties("LimitVertices") = 2
  307.     OnNewGraphic = True
  308.     Exit Function
  309.  
  310. Failed:
  311.     'Return false on failure
  312.     OnNewGraphic = False
  313. End Function
  314.  
  315. 'Function called whenever a copy of a graphic is being made
  316. Public Function OnCopyGraphic(ByVal grfCopy As Object, ByVal grfSource As Object) As Boolean
  317.     'Return false on failure
  318.     OnCopyGraphic = True
  319. End Function
  320.  
  321. 'Notification function called after graphic property is saved
  322. Public Function OnPropertyChanged(ByVal Graphic As Object, ByVal PropID As Long, _
  323.         ValueOld As Variant, ValueNew As Variant)
  324.     'Do nothing
  325. End Function
  326.  
  327. 'Notification function called when graphic property is saved
  328. Public Function OnPropertyChanging(ByVal Graphic As Object, ByVal PropID As Long, _
  329.         ValueOld As Variant, ValueNew As Variant) As Boolean
  330.     'OK to proceed
  331.     OnPropertyChanging = True
  332. End Function
  333.  
  334. 'Notification function called when graphic property is retrieved
  335. Public Function OnPropertyGet(ByVal Graphic As Object, ByVal PropID As Long)
  336.     'Do nothing
  337. End Function
  338.  
  339. 'Called when we need to update our object
  340. Public Function Regen(ByVal grfThis As Object)
  341.         'Setup error handler
  342.         On Error GoTo Failed
  343.  
  344.         'Set up lock (prevent recursion)
  345.         Dim LockCount&
  346.         LockCount& = grfThis.RegenLock
  347.  
  348.         'Setup error handler (make sure lock is removed)
  349.         On Error GoTo FailedLock
  350.         If LockCount& = 0 Then
  351.             'Delete any previous cosmetic children
  352.             grfThis.Graphics.Clear gfCosmetic
  353.             
  354. Dim BoltType As Long
  355.             BoltType = grfThis.Properties("BoltType")
  356. Dim NutType As Long
  357.             NutType = grfThis.Properties("NutType")
  358. Dim iDiam%
  359. '            iDiam = grfThis.Properties("Diameter")
  360.  
  361. Dim dd#, D#, H#, T#, j#, del#, E#, F#
  362. Dim HBolt, HNut, HWasher
  363.             
  364. '            dd = CDbl(frmBoltNut.ListDiam.List(iDiam))
  365.             dd = grfThis.Properties("Diameter")
  366.             
  367. Dim Salp#, Calp#, L#, alp#
  368. Dim X00#, Y00#, X01#, Y01#
  369.             With grfThis.Vertices
  370.                 X00 = .Item(0).X
  371.                 Y00 = .Item(0).Y
  372.                 X01 = .Item(1).X
  373.                 Y01 = .Item(1).Y
  374.                 L = Sqr((X01 - X00) * (X01 - X00) + (Y01 - Y00) * (Y01 - Y00))
  375.                 Salp = (Y01 - Y00) / L
  376.                 Calp = (X01 - X00) / L
  377.             End With
  378.             
  379.        If Calp = 0# Then
  380.           If Salp > 0 Then
  381.               alp = Pi / 2#
  382.               GoTo LL
  383.           End If
  384.           If Salp < 0 Then
  385.               alp = 3# * Pi / 2#
  386.               GoTo LL
  387.           End If
  388.        End If
  389.             
  390.        If Salp >= 0# And Calp > 0# Then
  391.           alp = Atn(Abs(Salp / Calp))
  392.        End If
  393.        If Salp >= 0# And Calp < 0# Then
  394.           alp = Pi - Atn(Abs(Salp / Calp))
  395.        End If
  396.        If Salp <= 0# And Calp < 0# Then
  397.           alp = Pi + Atn(Abs(Salp / Calp))
  398.        End If
  399.        If Salp <= 0# And Calp > 0# Then
  400.           alp = 2# * Pi - Atn(Abs(Salp / Calp))
  401.        End If
  402. LL:
  403.             
  404.             
  405. Dim X0(30) As Double
  406. Dim Y0(30) As Double
  407. Dim X(30) As Double
  408. Dim Y(30) As Double
  409.        
  410. Dim i As Integer
  411. Dim grfChild As Object
  412.        
  413.        
  414.  ' Slotted Countersunk Bolt  Slotted Countersunk Bolt  Slotted Countersunk Bolt
  415.  ' Slotted Countersunk Bolt  Slotted Countersunk Bolt  Slotted Countersunk Bolt
  416.     
  417.     If BoltType = 0 Then
  418.        
  419.         D = 1.875 * dd
  420.         H = 0.494 * dd
  421.         T = 0.24 * dd
  422.         j = 0.19 * dd
  423.         del = 0.1 * dd
  424.         HBolt = H
  425.         
  426.  ' Head of the Bolt
  427.        X0(1) = H
  428.        Y0(1) = dd / 2#
  429.        
  430.        X0(2) = X0(1)
  431.        Y0(2) = -Y0(1)
  432.        
  433.        X0(3) = 0#
  434.        Y0(3) = D / 2#
  435.        
  436.        X0(4) = X0(3)
  437.        Y0(4) = -Y0(3)
  438.        
  439.        X0(5) = X0(3)
  440.        Y0(5) = j / 2#
  441.        
  442.        X0(6) = X0(3)
  443.        Y0(6) = -Y0(5)
  444.        
  445.        X0(7) = X0(3) + T
  446.        Y0(7) = Y0(5)
  447.        
  448.        X0(8) = X0(7)
  449.        Y0(8) = Y0(6)
  450.        
  451.        For i = 1 To 8
  452.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  453.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  454.        Next i
  455.        
  456.             'Add child Graphics
  457.       '1
  458.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(2), Y(2), 0#)
  459.                   grfChild.Cosmetic = True
  460.        '2
  461.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(3), Y(3), 0#)
  462.                   grfChild.Cosmetic = True
  463.        '3
  464.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(4), Y(4), 0#)
  465.                   grfChild.Cosmetic = True
  466.        '4
  467.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(5), Y(5), 0#)
  468.                   grfChild.Cosmetic = True
  469.        '5
  470.        Set grfChild = grfThis.Graphics.AddLineSingle(X(4), Y(4), 0#, X(6), Y(6), 0#)
  471.                   grfChild.Cosmetic = True
  472.        '6
  473.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(7), Y(7), 0#)
  474.                   grfChild.Cosmetic = True
  475.        '7
  476.        Set grfChild = grfThis.Graphics.AddLineSingle(X(6), Y(6), 0#, X(8), Y(8), 0#)
  477.                   grfChild.Cosmetic = True
  478.        '8
  479.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(8), Y(8), 0#)
  480.                   grfChild.Cosmetic = True
  481.    End If
  482.    
  483.    
  484. ' Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt
  485. ' Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt  Hex Bolt
  486.     
  487.     If BoltType = 1 Then
  488.         D = 1.75 * dd
  489.         H = 0.65 * dd
  490.         E = 0.8 * H
  491.         F = D / 4#
  492.         del = 0.1 * dd
  493.         HBolt = H
  494.        
  495. '-----------------------------------------------------------
  496.   ' Head of the Bolt
  497.        X0(1) = H
  498.        Y0(1) = D / 2#
  499.        
  500.        X0(2) = X0(1)
  501.        Y0(2) = -Y0(1)
  502.        
  503.        X0(3) = X0(1)
  504.        Y0(3) = F
  505.        
  506.        X0(4) = X0(1)
  507.        Y0(4) = -Y0(3)
  508.        
  509.        X0(5) = H - E
  510.        Y0(5) = D / 2#
  511.        
  512.        X0(6) = X0(5)
  513.        Y0(6) = -Y0(5)
  514.        
  515.        X0(7) = 0#
  516.        Y0(7) = D / 2# - (H - E)
  517.        
  518.        X0(8) = X0(7)
  519.        Y0(8) = -Y0(7)
  520.        
  521.        X0(9) = X0(5)
  522.        Y0(9) = Y0(3)
  523.        
  524.        X0(10) = X0(9)
  525.        Y0(10) = -Y0(9)
  526.        
  527.        X0(11) = 0#
  528.        Y0(11) = 3# / 2# * F
  529.        
  530.        X0(12) = X0(11)
  531.        Y0(12) = 0#
  532.        
  533.        X0(13) = X0(11)
  534.        Y0(13) = -Y0(11)
  535.        
  536.             
  537.        
  538.        
  539.        For i = 1 To 13
  540.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  541.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  542.        Next i
  543.        
  544.             'Add child Graphics
  545. '---------------------------------------------------------
  546.        '6
  547.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(2), Y(2), 0#)
  548.                   grfChild.Cosmetic = True
  549.        '7
  550.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(5), Y(5), 0#)
  551.                   grfChild.Cosmetic = True
  552.        '8
  553.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(6), Y(6), 0#)
  554.                   grfChild.Cosmetic = True
  555.        '9
  556.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(9), Y(9), 0#)
  557.                   grfChild.Cosmetic = True
  558.        '10
  559.        Set grfChild = grfThis.Graphics.AddLineSingle(X(4), Y(4), 0#, X(10), Y(10), 0#)
  560.                   grfChild.Cosmetic = True
  561.        '11
  562.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(8), Y(8), 0#)
  563.                   grfChild.Cosmetic = True
  564.        '12
  565.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(7), Y(7), 0#)
  566.                   grfChild.Cosmetic = True
  567.        '13
  568.        Set grfChild = grfThis.Graphics.AddLineSingle(X(6), Y(6), 0#, X(8), Y(8), 0#)
  569.                   grfChild.Cosmetic = True
  570.        '14
  571.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(5), Y(5), 0#, X(11), Y(11), 0#, X(9), Y(9), 0#)
  572.                   grfChild.Cosmetic = True
  573.        '15
  574.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(9), Y(9), 0#, X(12), Y(12), 0#, X(10), Y(10), 0#)
  575.                   grfChild.Cosmetic = True
  576.        '16
  577.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(10), Y(10), 0#, X(13), Y(13), 0#, X(6), Y(6), 0#)
  578.                   grfChild.Cosmetic = True
  579.                   
  580.                                                                  
  581.    End If
  582.    
  583.    
  584.    
  585.    
  586.  ' Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut
  587.  ' Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut  Hex Nut
  588.  
  589.    If NutType = 0 Then
  590.         D = 1.8 * dd
  591.         H = 0.875 * dd
  592.         E = 0.8 * H
  593.         F = D / 4#
  594.         del = (H - E) / 2#
  595.         HNut = H
  596.     
  597.        
  598.        X0(1) = L - HNut - dd / 4#
  599.        Y0(1) = -D / 2# + del
  600.    
  601.        X0(2) = X0(1)
  602.        Y0(2) = -Y0(1)
  603.        
  604.        X0(3) = X0(1) + del
  605.        Y0(3) = Y0(2) + del
  606.        
  607.        X0(4) = X0(1) + H - del
  608.        Y0(4) = Y0(3)
  609.        
  610.        X0(5) = X0(1) + H
  611.        Y0(5) = Y0(4) - del
  612.        
  613.        X0(6) = X0(5)
  614.        Y0(6) = -Y0(5)
  615.        
  616.        X0(7) = X0(6) - del
  617.        Y0(7) = -Y0(4)
  618.        
  619.        X0(8) = X0(1) + del
  620.        Y0(8) = -Y0(3)
  621.        
  622.        X0(9) = X0(1)
  623.        Y0(9) = 3# / 2# * F
  624.        
  625.        X0(10) = X0(1)
  626.        Y0(10) = 0#
  627.        
  628.        X0(11) = X0(1)
  629.        Y0(11) = -Y0(9)
  630.        
  631.        X0(12) = X0(1) + del
  632.        Y0(12) = F
  633.        
  634.        X0(13) = X0(12)
  635.        Y0(13) = -Y0(12)
  636.        
  637.        X0(14) = X0(12) + E
  638.        Y0(14) = Y0(12)
  639.        
  640.        X0(15) = X0(14)
  641.        Y0(15) = Y0(13)
  642.        
  643.        X0(16) = X0(5)
  644.        Y0(16) = Y0(9)
  645.        
  646.        X0(17) = X0(5)
  647.        Y0(17) = Y0(10)
  648.        
  649.        X0(18) = X0(5)
  650.        Y0(18) = Y0(11)
  651.        
  652.        
  653.        For i = 1 To 18
  654.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  655.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  656.        Next i
  657.       '1
  658.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(2), Y(2), 0#)
  659.                   grfChild.Cosmetic = True
  660.       '2
  661.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(3), Y(3), 0#)
  662.                   grfChild.Cosmetic = True
  663.       '3
  664.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(4), Y(4), 0#)
  665.                   grfChild.Cosmetic = True
  666.       '4
  667.        Set grfChild = grfThis.Graphics.AddLineSingle(X(4), Y(4), 0#, X(5), Y(5), 0#)
  668.                   grfChild.Cosmetic = True
  669.       '5
  670.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(6), Y(6), 0#)
  671.                   grfChild.Cosmetic = True
  672.       '6
  673.        Set grfChild = grfThis.Graphics.AddLineSingle(X(6), Y(6), 0#, X(7), Y(7), 0#)
  674.                   grfChild.Cosmetic = True
  675.       '7
  676.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(8), Y(8), 0#)
  677.                   grfChild.Cosmetic = True
  678.       '8
  679.        Set grfChild = grfThis.Graphics.AddLineSingle(X(8), Y(8), 0#, X(1), Y(1), 0#)
  680.                   grfChild.Cosmetic = True
  681. '---------------------------------------------------------------
  682.        '9
  683.        Set grfChild = grfThis.Graphics.AddLineSingle(X(13), Y(13), 0#, X(15), Y(15), 0#)
  684.                   grfChild.Cosmetic = True
  685.        '10
  686.        Set grfChild = grfThis.Graphics.AddLineSingle(X(12), Y(12), 0#, X(14), Y(14), 0#)
  687.                   grfChild.Cosmetic = True
  688. '-----------------------------------------------------------------
  689.        '11
  690.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(9), Y(9), 0#, X(12), Y(12), 0#)
  691.                   grfChild.Cosmetic = True
  692.        '12
  693.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(12), Y(12), 0#, X(10), Y(10), 0#, X(13), Y(13), 0#)
  694.                   grfChild.Cosmetic = True
  695.        '13
  696.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(13), Y(13), 0#, X(11), Y(11), 0#, X(8), Y(8), 0#)
  697.                   grfChild.Cosmetic = True
  698.        '14
  699.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(4), Y(4), 0#, X(16), Y(16), 0#, X(14), Y(14), 0#)
  700.                   grfChild.Cosmetic = True
  701.        '15
  702.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(14), Y(14), 0#, X(17), Y(17), 0#, X(15), Y(15), 0#)
  703.                   grfChild.Cosmetic = True
  704.        '16
  705.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(15), Y(15), 0#, X(18), Y(18), 0#, X(7), Y(7), 0#)
  706.                   grfChild.Cosmetic = True
  707.                   
  708.  ' End Of Bolt  End Of Bolt  End Of Bolt  End Of Bolt
  709.        del = 0.1 * dd
  710.         
  711.        X0(1) = L - dd / 4#
  712.        Y0(1) = dd / 2#
  713.        
  714.        X0(2) = X0(1)
  715.        Y0(2) = -Y0(1)
  716.        
  717.        X0(3) = X0(1) + dd / 4# - del
  718.        Y0(3) = dd / 2#
  719.        
  720.        X0(4) = X0(3)
  721.        Y0(4) = -Y0(3)
  722.        
  723.        X0(5) = X0(3) + del
  724.        Y0(5) = dd / 2# - del
  725.        
  726.        X0(6) = X0(5)
  727.        Y0(6) = -Y0(5)
  728.                   
  729.        X0(7) = X0(1)
  730.        Y0(7) = Y0(1) - del
  731.                   
  732.        X0(8) = X0(7)
  733.        Y0(8) = -Y0(7)
  734.                   
  735.        X0(9) = X0(5) + 2#
  736.        Y0(9) = 0#
  737.                   
  738.        For i = 1 To 9
  739.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  740.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  741.        Next i
  742.        
  743.        '0
  744.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(4), Y(4), 0#)
  745.                   grfChild.Cosmetic = True
  746.       '1
  747.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(3), Y(3), 0#)
  748.                   grfChild.Cosmetic = True
  749.        '2
  750.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(4), Y(4), 0#)
  751.                   grfChild.Cosmetic = True
  752.        '3
  753.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(5), Y(5), 0#)
  754.                   grfChild.Cosmetic = True
  755.        '4
  756.        Set grfChild = grfThis.Graphics.AddLineSingle(X(4), Y(4), 0#, X(6), Y(6), 0#)
  757.                   grfChild.Cosmetic = True
  758.        '5
  759.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(6), Y(6), 0#)
  760.                   grfChild.Cosmetic = True
  761. '--------------------
  762.                   
  763.         '6
  764.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(7), Y(7), 0#)
  765.                   grfChild.Cosmetic = True
  766.         '7
  767.        Set grfChild = grfThis.Graphics.AddLineSingle(X(6), Y(6), 0#, X(8), Y(8), 0#)
  768.                   grfChild.Cosmetic = True
  769. '----------------------------------------------------
  770.  
  771. ' Middle of Bolt
  772.                   
  773.        X0(1) = HBolt
  774.        Y0(1) = dd / 2#
  775.    
  776.        X0(2) = X0(1)
  777.        Y0(2) = -Y0(1)
  778.        
  779.        X0(3) = L - HNut - dd / 4#
  780.        Y0(3) = Y0(1)
  781.        
  782.        X0(4) = X0(3)
  783.        Y0(4) = Y0(2)
  784. ' Threads
  785.        X0(5) = (X0(1) + X0(3)) / 2#
  786.        Y0(5) = Y0(1)
  787.        
  788.        X0(6) = X0(5)
  789.        Y0(6) = -Y0(5)
  790.        
  791.        X0(7) = X0(5)
  792.        Y0(7) = Y0(1) - del
  793.        
  794.        X0(8) = X0(5)
  795.        Y0(8) = -Y0(7)
  796.                   
  797.        X0(9) = X0(3)
  798.        Y0(9) = Y0(7)
  799.        
  800.        X0(10) = X0(9)
  801.        Y0(10) = -Y0(9)
  802.        
  803.        For i = 1 To 10
  804.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  805.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  806.        Next i
  807.       '1
  808.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(3), Y(3), 0#)
  809.                   grfChild.Cosmetic = True
  810.       '2
  811.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(4), Y(4), 0#)
  812.                   grfChild.Cosmetic = True
  813.       '3
  814.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(6), Y(6), 0#)
  815.                   grfChild.Cosmetic = True
  816.       '4
  817.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(9), Y(9), 0#)
  818.                   grfChild.Cosmetic = True
  819.       '5
  820.        Set grfChild = grfThis.Graphics.AddLineSingle(X(8), Y(8), 0#, X(10), Y(10), 0#)
  821.                   grfChild.Cosmetic = True
  822.                               
  823.     End If
  824.     
  825.     
  826. ' Low Crown Nut  Low Crown Nut  Low Crown Nut  Low Crown Nut  Low Crown Nut
  827. ' Low Crown Nut  Low Crown Nut  Low Crown Nut  Low Crown Nut  Low Crown Nut
  828.    
  829.    If NutType = 1 Then
  830.    
  831.         D = 1.66 * dd
  832.         H = 0.72 * dd
  833.         E = 0.8 * H
  834.         F = D / 4#
  835.         del = (H - E) / 2#
  836.         HNut = H + (D / 2# - del) * 1.2
  837.     
  838.        
  839.        X0(1) = L - HNut
  840.        Y0(1) = -D / 2# + del
  841.    
  842.        X0(2) = X0(1)
  843.        Y0(2) = -Y0(1)
  844.        
  845.        X0(3) = X0(1) + del
  846.        Y0(3) = Y0(2) + del
  847.        
  848.        X0(4) = X0(1) + H - del
  849.        Y0(4) = Y0(3)
  850.        
  851.        X0(5) = X0(1) + H
  852.        Y0(5) = Y0(4) - del
  853.        
  854.        X0(6) = X0(5)
  855.        Y0(6) = -Y0(5)
  856.        
  857.        X0(7) = X0(6) - del
  858.        Y0(7) = -Y0(4)
  859.        
  860.        X0(8) = X0(1) + del
  861.        Y0(8) = -Y0(3)
  862.        
  863.        X0(9) = X0(1)
  864.        Y0(9) = 3# / 2# * F
  865.        
  866.        X0(10) = X0(1)
  867.        Y0(10) = 0#
  868.        
  869.        X0(11) = X0(1)
  870.        Y0(11) = -Y0(9)
  871.        
  872.        X0(12) = X0(1) + del
  873.        Y0(12) = F
  874.        
  875.        X0(13) = X0(12)
  876.        Y0(13) = -Y0(12)
  877.        
  878.        X0(14) = X0(12) + E
  879.        Y0(14) = Y0(12)
  880.        
  881.        X0(15) = X0(14)
  882.        Y0(15) = Y0(13)
  883.        
  884.        X0(16) = X0(5)
  885.        Y0(16) = Y0(9)
  886.        
  887.        X0(17) = X0(5)
  888.        Y0(17) = Y0(10)
  889.        
  890.        X0(18) = X0(5)
  891.        Y0(18) = Y0(11)
  892.        
  893.        X0(19) = X0(17) + (Y0(5) - Y0(17)) * 1.2
  894.        Y0(19) = 0#
  895.       
  896.        
  897.        
  898.        For i = 1 To 19
  899.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  900.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  901.        Next i
  902.       '1
  903.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(2), Y(2), 0#)
  904.                   grfChild.Cosmetic = True
  905.       '2
  906.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(3), Y(3), 0#)
  907.                   grfChild.Cosmetic = True
  908.       '3
  909.        Set grfChild = grfThis.Graphics.AddLineSingle(X(3), Y(3), 0#, X(4), Y(4), 0#)
  910.                   grfChild.Cosmetic = True
  911.       '4
  912.        Set grfChild = grfThis.Graphics.AddLineSingle(X(4), Y(4), 0#, X(5), Y(5), 0#)
  913.                   grfChild.Cosmetic = True
  914.       '5
  915.        Set grfChild = grfThis.Graphics.AddArcRotatedElliptical(X(17), Y(17), 0#, X(5), Y(5), 0#, X(19), Y(19), 0#, Pi, 2# * Pi)
  916.                   grfChild.Cosmetic = True
  917.       '6
  918.        Set grfChild = grfThis.Graphics.AddLineSingle(X(6), Y(6), 0#, X(7), Y(7), 0#)
  919.                   grfChild.Cosmetic = True
  920.       '7
  921.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(8), Y(8), 0#)
  922.                   grfChild.Cosmetic = True
  923.       '8
  924.        Set grfChild = grfThis.Graphics.AddLineSingle(X(8), Y(8), 0#, X(1), Y(1), 0#)
  925.                   grfChild.Cosmetic = True
  926. '---------------------------------------------------------------
  927.        '9
  928.        Set grfChild = grfThis.Graphics.AddLineSingle(X(13), Y(13), 0#, X(15), Y(15), 0#)
  929.                   grfChild.Cosmetic = True
  930.        '10
  931.        Set grfChild = grfThis.Graphics.AddLineSingle(X(12), Y(12), 0#, X(14), Y(14), 0#)
  932.                   grfChild.Cosmetic = True
  933. '-----------------------------------------------------------------
  934.        '11
  935.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(3), Y(3), 0#, X(9), Y(9), 0#, X(12), Y(12), 0#)
  936.                   grfChild.Cosmetic = True
  937.        '12
  938.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(12), Y(12), 0#, X(10), Y(10), 0#, X(13), Y(13), 0#)
  939.                   grfChild.Cosmetic = True
  940.        '13
  941.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(13), Y(13), 0#, X(11), Y(11), 0#, X(8), Y(8), 0#)
  942.                   grfChild.Cosmetic = True
  943.        '14
  944.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(4), Y(4), 0#, X(16), Y(16), 0#, X(14), Y(14), 0#)
  945.                   grfChild.Cosmetic = True
  946.        '15
  947.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(14), Y(14), 0#, X(17), Y(17), 0#, X(15), Y(15), 0#)
  948.                   grfChild.Cosmetic = True
  949.        '16
  950.        Set grfChild = grfThis.Graphics.AddArcTriplePoint(X(15), Y(15), 0#, X(18), Y(18), 0#, X(7), Y(7), 0#)
  951.                   grfChild.Cosmetic = True
  952.                   
  953. '----------------------------------------------------
  954.  
  955. ' Middle of Bolt
  956.                   
  957.        X0(1) = HBolt
  958.        Y0(1) = dd / 2#
  959.    
  960.        X0(2) = X0(1)
  961.        Y0(2) = -Y0(1)
  962.        
  963.        X0(3) = L - HNut
  964.        Y0(3) = Y0(1)
  965.        
  966.        X0(4) = X0(3)
  967.        Y0(4) = Y0(2)
  968. ' Threads
  969.        X0(5) = (X0(1) + X0(3)) / 2#
  970.        Y0(5) = Y0(1)
  971.        
  972.        X0(6) = X0(5)
  973.        Y0(6) = -Y0(5)
  974.        
  975.        X0(7) = X0(5)
  976.        Y0(7) = Y0(1) - del
  977.        
  978.        X0(8) = X0(5)
  979.        Y0(8) = -Y0(7)
  980.                   
  981.        X0(9) = X0(3)
  982.        Y0(9) = Y0(7)
  983.        
  984.        X0(10) = X0(9)
  985.        Y0(10) = -Y0(9)
  986.        
  987.        For i = 1 To 10
  988.           X(i) = X00 + X0(i) * Calp - Y0(i) * Salp
  989.           Y(i) = Y00 + X0(i) * Salp + Y0(i) * Calp
  990.        Next i
  991.       '1
  992.        Set grfChild = grfThis.Graphics.AddLineSingle(X(1), Y(1), 0#, X(3), Y(3), 0#)
  993.                   grfChild.Cosmetic = True
  994.       '2
  995.        Set grfChild = grfThis.Graphics.AddLineSingle(X(2), Y(2), 0#, X(4), Y(4), 0#)
  996.                   grfChild.Cosmetic = True
  997.       '3
  998.        Set grfChild = grfThis.Graphics.AddLineSingle(X(5), Y(5), 0#, X(6), Y(6), 0#)
  999.                   grfChild.Cosmetic = True
  1000.       '4
  1001.        Set grfChild = grfThis.Graphics.AddLineSingle(X(7), Y(7), 0#, X(9), Y(9), 0#)
  1002.                   grfChild.Cosmetic = True
  1003.       '5
  1004.        Set grfChild = grfThis.Graphics.AddLineSingle(X(8), Y(8), 0#, X(10), Y(10), 0#)
  1005.                   grfChild.Cosmetic = True
  1006.                               
  1007.                                            
  1008.    End If
  1009.     
  1010.  
  1011.             'Add visible child Graphics
  1012.         End If
  1013.  
  1014.         grfThis.RegenUnlock
  1015.         Exit Function
  1016.  
  1017. FailedLock:
  1018.         'Remove lock
  1019.         grfThis.RegenUnlock
  1020.  
  1021. Failed:
  1022. End Function
  1023.  
  1024. Public Function Draw(ByVal grfThis As Object, ByVal view As Object, Optional mat As Variant) As Boolean
  1025.     'Return True if we did the redraw (no further processing necessary, no children will be drawn).
  1026.     'Since this is just a test, we return False to let TurboCAD do the drawing operation.
  1027.     Draw = False
  1028. End Function
  1029.  
  1030. ' Form string from string with symbols
  1031. Private Function StringToSize(Str As String) As Double
  1032. Dim CharInt(10) As String, j%
  1033.     CharInt(0) = "0"
  1034.     CharInt(1) = "1"
  1035.     CharInt(2) = "2"
  1036.     CharInt(3) = "3"
  1037.     CharInt(4) = "4"
  1038.     CharInt(5) = "5"
  1039.     CharInt(6) = "6"
  1040.     CharInt(7) = "7"
  1041.     CharInt(8) = "8"
  1042.     CharInt(9) = "9"
  1043. Dim StrLen%, i%
  1044. Dim Char$, ResStr$
  1045.     ResStr = ""
  1046.     StrLen = Len(Str)
  1047.     For i = 1 To StrLen
  1048.         Char = VBA.Mid(Str, i, 1)
  1049.         If Char = "0" Or Char = "1" Or Char = "2" Or Char = "3" Or Char = "4" Or Char = "5" Or Char = "6" Or Char = "7" Or Char = "8" Or Char = "9" Or Char = "." Or Char = "," Then
  1050. '            If Char = "," Then Char = "."
  1051.             ResStr = ResStr & Char
  1052.         End If
  1053.     Next i
  1054.     For i = 1 To StrLen
  1055.         Char = VBA.Mid(Str, i, 1)
  1056.         If Char = "-" Then
  1057.             ResStr = Char & ResStr
  1058.             Exit For
  1059.         End If
  1060.     Next i
  1061.     StringToSize = CDbl(ResStr)
  1062. End Function
  1063.  
  1064.  
  1065.